package com.cskaoyan.service;

import com.cskaoyan.anno.CountTime;
import org.springframework.stereotype.Service;

/**
 * @author stone
 * @date 2022/07/07 11:22
 */
@Service
public class UserServiceImpl implements UserService {
    @CountTime
    @Override
    public void sayHello() {
        System.out.println("hello aop");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    @CountTime
    @Override
    public void sayGoodbye() {
        System.out.println("byebeye");
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void sayGoodMorning() {
        System.out.println("早上好");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    @CountTime
    @Override
    public int add(int num1, int num2) {
        int result = num1 + num2;
        System.out.println("相加的结果：" + result);
        return result;
    }

    @CountTime
    @Override
    public void createException() {
        System.out.println("执行委托类方法");
        int i = 1 / 0;
    }
}
